#!/bin/sh
#
#

BUILDDATE=$(date +%F)

MAJORVERSION=`sed '/^\#/d' version.properties | grep 'major'  | tail -n 1 | sed 's/^.*=//;s/^[[:space:]]*//;s/[[:space:]]*$//'`
MINORVERSION=`sed '/^\#/d' version.properties | grep 'minor'  | tail -n 1 | sed 's/^.*=//;s/^[[:space:]]*//;s/[[:space:]]*$//'`

echo "Version: $MAJORVERSION.$MINORVERSION"
echo "Build date: $BUILDDATE"

BUILDDIR="yabetbuild"
BUILDNAME="yabet-linux-qt4.5-$MAJORVERSION.$MINORVERSION"
RELEASEDIR="$BUILDDIR/$BUILDNAME"

echo "Build dir: $RELEASEDIR"

sed -i "s/%test-major-version%/$MAJORVERSION/g" yabetversion.cpp
sed -i "s/%test-minor-version%/$MINORVERSION/g" yabetversion.cpp
sed -i "s/%test-date%/$BUILDDATE/g" yabetversion.cpp

~/qtsdk-2009.01/qt/bin/qmake yabet.pro -spec linux-g++-qt4.5 -r 
make

svn revert yabetversion.cpp

rm -rf $RELEASEDIR
rm -rf $RELEASEDIR.tar.gz

mkdir -p $RELEASEDIR
cp -rf yabet $RELEASEDIR/

mkdir $RELEASEDIR/markups
cp -rf markups/*.properties $RELEASEDIR/markups
cp -rf license $RELEASEDIR/
cp -rf changes $RELEASEDIR/

cd $BUILDDIR
tar -pczf $BUILDNAME.tar.gz $BUILDNAME
